ipython基础
# 在Python中执行命令
import subprocess
subprocess.call(["ls","-l","/tmp"])

subprocess.call(["some_command","选项","路径"])



#!/usr/bin/env python

#pysysinfo_func.py
import subprocess
 
#Command 1
def uname_func():
    uname = "uname"
    uname_arg ="-a"
    print "Gathering System information with %s command:\n" % uname
    subprocess.call([uname,uname_arg])
 
#Command 2
def disk_func():
    diskspace = "df"
    diskspace_arg = "-h"
    print "Gathering diskspace information %s command:\n" % diskspace
    subprocess.call([diskspace,diskspace_arg])
 
#Main function that call other functions
def main():
    uname_func()
    disk_func()
 
main()
 
#ipython
alias achoo echo "|%l|"
可传参数
alias achoo ech first: "|%s|", second: "|%s|"
参数少了会报错
achoo foo bar
 
!netstat -antlp
